package project.parser.ast.util;

import project.environments.DynamicEnv;
import project.parser.ast.exps.Exp;

public class EvalUtil {
	private EvalUtil() {
	}

	public static boolean[] evalBoolArgs(DynamicEnv denv, Exp... exps) {
		final boolean[] res = new boolean[exps.length];
		int i = 0;
		for (Exp exp : exps)
			res[i++] = exp.evaluate(denv).asBoolean();
		return res;
	}

	public static int[] evalIntArgs(DynamicEnv denv, Exp... exps) {
		final int[] res = new int[exps.length];
		int i = 0;
		for (Exp exp : exps)
			res[i++] = exp.evaluate(denv).asInteger();
		return res;
	}

	public static boolean evalBoolArg(DynamicEnv denv, Exp exp) {
		return evalBoolArgs(denv, exp)[0];
	}

	public static int evalIntArg(DynamicEnv denv, Exp exp) {
		return evalIntArgs(denv, exp)[0];
	}
}
